﻿// <copyright file="AlertConfigurationElement.cs" company="http://www.dymetis.com">
//
// Copyright (c) 2011 Eddie Z. Lin.
//
// This source is subject to the Microsoft Public License.
// See http://www.opensource.org/licenses/ms-pl.
// All other rights reserved.
// 
// </copyright>

namespace Dymetis.TeamAlert.Configuration
{
    using System.ComponentModel;
    using System.Configuration;

    /// <summary>
    /// The AlertConfigurationElement Configuration Element.
    /// </summary>
    public partial class AlertConfigurationElement : ConfigurationElement
    {
        /// <summary>
        /// The XML name of the <see cref="Name"/> property.
        /// </summary>
        internal const string NamePropertyName = "name";

        /// <summary>
        /// The XML name of the <see cref="Event"/> property.
        /// </summary>
        internal const string EventPropertyName = "event";

        /// <summary>
        /// The XML name of the <see cref="FilterExpression"/> property.
        /// </summary>
        internal const string FilterExpressionPropertyName = "filterExpression";

        /// <summary>
        /// The XML name of the <see cref="Recipients"/> property.
        /// </summary>
        internal const string RecipientsPropertyName = "recipients";

        /// <summary>
        /// Gets or sets the Name.
        /// </summary>
        [Description("The Name.")]
        [ConfigurationProperty(AlertConfigurationElement.NamePropertyName, IsRequired = true, IsKey = true, IsDefaultCollection = false)]
        public string Name
        {
            get
            {
                return (string)base[AlertConfigurationElement.NamePropertyName];
            }

            set
            {
                base[AlertConfigurationElement.NamePropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets the Event.
        /// </summary>
        [Description("The Event.")]
        [ConfigurationProperty(AlertConfigurationElement.EventPropertyName, IsRequired = true, IsKey = false, IsDefaultCollection = false)]
        public string Event
        {
            get
            {
                return (string)base[AlertConfigurationElement.EventPropertyName];
            }

            set
            {
                base[AlertConfigurationElement.EventPropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets the FilterExpression.
        /// </summary>
        [Description("The FilterExpression.")]
        [ConfigurationProperty(AlertConfigurationElement.FilterExpressionPropertyName, IsRequired = false, IsKey = false, IsDefaultCollection = false)]
        public string FilterExpression
        {
            get
            {
                return (string)base[AlertConfigurationElement.FilterExpressionPropertyName];
            }

            set
            {
                base[AlertConfigurationElement.FilterExpressionPropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets the Recipients.
        /// </summary>
        [Description("The Recipients.")]
        [ConfigurationProperty(AlertConfigurationElement.RecipientsPropertyName, IsRequired = false, IsKey = false, IsDefaultCollection = false)]
        public RecipientConfigurationElementCollection Recipients
        {
            get
            {
                return (RecipientConfigurationElementCollection)base[AlertConfigurationElement.RecipientsPropertyName];
            }

            set
            {
                base[AlertConfigurationElement.RecipientsPropertyName] = value;
            }
        }

        /// <summary>
        /// Gets a value indicating whether the element is read-only.
        /// </summary>
        /// <returns>
        /// A value indicating whether the element is read-only.
        /// </returns>
        public override bool IsReadOnly()
        {
            return false;
        }
    }
}
